import { Log } from '../utils/Log';
import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
let TAG:string = "YW_"
export default class EntryAbility extends UIAbility {
    onCreate(want, launchParam) {
        Log.i(TAG,"EntryAbility onCreate");
        globalThis.context = this.context
        globalThis.launchWant = this.launchWant
        globalThis.permissionFlag = false
        globalThis.demoStartTime = new Date().getTime()
        globalThis.demoStartFlag = true
        globalThis.doOnForeground = false
        globalThis.appFilePath = "xxx"
    }

    onDestroy() {
        Log.i(TAG,"EntryAbility onDestroy");
    }

    onWindowStageCreate(windowStage: window.WindowStage) {
        // Main window is created, set main page for this ability
        Log.i(TAG,"EntryAbility onWindowStageCreate");

        windowStage.loadContent('pages/Index', (err, data) => {
            if (err.code) {
                Log.e(TAG, `Failed to load the content. Cause: ${JSON.stringify(err) ?? ''}s`);
                return;
            }
            Log.i(TAG, 'Succeeded in loading the content. Data: %{public}s');
        });
    }

    onWindowStageDestroy() {
        // Main window is destroyed, release UI related resources
        Log.i(TAG, '%{public}s', 'Ability onWindowStageDestroy');
    }

    onForeground() {
        // Ability has brought to foreground
        Log.i(TAG, '%{public}s', 'Ability onForeground');
    }

    onBackground() {
        // Ability has back to background
        Log.i(TAG, '%{public}s', 'Ability onBackground');
    }
}
